home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / servers / key_defs.h < prev    next >
C/C++ Source or Header  |  1990-01-22  |  2KB  |  90 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * key_defs.h
  9.  *
  10.  * $Source: /../wb1/usr/netmsg/src/RCS/key_defs.h,v $
  11.  *
  12.  * $Header: key_defs.h,v 1.5 88/02/22 11:49:11 dpj Exp $
  13.  *
  14.  */
  15.  
  16. /*
  17.  * Definitions of encryption keys etc..
  18.  */
  19.  
  20. /*
  21.  * HISTORY:
  22.  *  5-Jun-87  Robert Sansom (rds) at Carnegie Mellon University
  23.  *    Added macros to convert keys between network and host order.
  24.  *
  25.  * 12-Apr-87  Robert Sansom (rds) at Carnegie Mellon University
  26.  *    Added KEY_IS_NULL.
  27.  *
  28.  *  2-Feb-87  Robert Sansom (rds) at Carnegie Mellon University
  29.  *    Added KEY_EQUAL.
  30.  *
  31.  *  5-Nov-86  Robert Sansom (rds) at Carnegie-Mellon University
  32.  *    Started.
  33.  *
  34.  */
  35.  
  36. #ifndef    _KEY_DEFS_
  37. #define    _KEY_DEFS_
  38.  
  39. /*
  40.  * An encrytion key.
  41.  */
  42. typedef union {
  43.     unsigned char    key_bytes[16];
  44.     unsigned long    key_longs[4];
  45. } key_t, *key_ptr_t;
  46.  
  47. #define KEY_EQUAL(key1, key2)                     \
  48.     ((key1.key_longs[0] == key2.key_longs[0])            \
  49.     && (key1.key_longs[1] == key2.key_longs[1])        \
  50.     && (key1.key_longs[2] == key2.key_longs[2])        \
  51.     && (key1.key_longs[3] == key2.key_longs[3]))
  52.  
  53. #define KEY_IS_NULL(key)                    \
  54.     (((key).key_longs[0] == 0) && ((key).key_longs[1] == 0)    \
  55.     && ((key).key_longs[2] == 0) && ((key).key_longs[3] == 0))
  56.  
  57.  
  58. /*
  59.  * Macros to convert keys between network and host byte order.
  60.  */
  61. #define NTOH_KEY(key) {                            \
  62.     (key).key_longs[0] = ntohl((key).key_longs[0]);            \
  63.     (key).key_longs[1] = ntohl((key).key_longs[1]);            \
  64.     (key).key_longs[2] = ntohl((key).key_longs[2]);            \
  65.     (key).key_longs[3] = ntohl((key).key_longs[3]);            \
  66. }
  67.  
  68. #define HTON_KEY(key) {                            \
  69.     (key).key_longs[0] = htonl((key).key_longs[0]);            \
  70.     (key).key_longs[1] = htonl((key).key_longs[1]);            \
  71.     (key).key_longs[2] = htonl((key).key_longs[2]);            \
  72.     (key).key_longs[3] = htonl((key).key_longs[3]);            \
  73. }
  74.  
  75. /*
  76.  * Structure used to transmit or store a token or a key.
  77.  */
  78. typedef union {
  79.     key_t    si_key;
  80.     key_t    si_token;
  81. } secure_info_t, *secure_info_ptr_t;
  82.  
  83. /*
  84.  * Security Level of ports and messages.
  85.  */
  86. #define PORT_NOT_SECURE        0
  87. #define MESSAGE_NOT_SECURE    0
  88.  
  89. #endif    _KEY_DEFS_
  90.